package com.shitou.pojo;

import java.util.List;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import com.shitou.util.DateUtil;

@Entity
@Table(name="t_project")
public class Project {

	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	private int id;
	
	private String name;
	private String createdate;
	private String updatedate;
	
	@ManyToMany
	@JoinTable(name="t_project_user",joinColumns=@JoinColumn(name="projectid"),inverseJoinColumns=@JoinColumn(name="userid"))
	private List<User> users;
	
	@OneToMany(mappedBy="project",fetch=FetchType.EAGER)
	private List<Milestone> milestones;
	
	@OneToMany(mappedBy="project",fetch=FetchType.LAZY)
	private List<Document> documents;
	
	@OneToMany(mappedBy="project",fetch=FetchType.LAZY)
	private List<Issues> issueses;
	
	//getter and setter
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getCreatedate() {
		return createdate == null ? null : DateUtil.friendlyTime(DateUtil.stringToDate(createdate));
	}
	public void setCreatedate(String createdate) {
		this.createdate = createdate;
	}
	public String getUpdatedate() {
		return updatedate;
	}
	public void setUpdatedate(String updatedate) {
		this.updatedate = updatedate;
	}
	public List<User> getUsers() {
		return users;
	}
	public void setUsers(List<User> users) {
		this.users = users;
	}
	public List<Milestone> getMilestones() {
		return milestones;
	}
	public void setMilestones(List<Milestone> milestones) {
		this.milestones = milestones;
	}
	public List<Document> getDocuments() {
		return documents;
	}
	public void setDocuments(List<Document> documents) {
		this.documents = documents;
	}
	public List<Issues> getIssueses() {
		return issueses;
	}
	public void setIssueses(List<Issues> issueses) {
		this.issueses = issueses;
	}
	
	
}
